import {fileURLToPath, URL} from 'node:url'
import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'
import ElementPlus from 'unplugin-element-plus/vite'
import {ElementPlusResolver} from 'unplugin-vue-components/resolvers'
import Components from 'unplugin-vue-components/vite'

export default defineConfig({
    plugins: [
        vue(),
        vueDevTools(),
        Components({
            resolvers: [
                ElementPlusResolver({
                    importStyle: "sass",
                }),
            ],
        }),
        ElementPlus({
            useSource: true,
        }),
    ],
    resolve: {
        alias: {
            '@': fileURLToPath(new URL('./src', import.meta.url))
        },
    },
    // css: {
    //     preprocessorOptions: {
    //         scss: {
    //             additionalData: `
    //             @use "@/styles/element/index.scss" as *;
    //             @use "@/styles/main.scss" as *;
    //             `,
    //         },
    //     },
    // },
    server: {
        host: '0.0.0.0',
        port: 8686,
        open: true,
        proxy: {
            '/api': {
                target: 'http://127.0.0.1:20000',
                // target:'http://127.0.0.1:6080',
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/api/, ''),
            }
        }
    }
})
